import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'path'
import eslint from 'vite-plugin-eslint'

// https://vitejs.dev/config/
export default defineConfig({
  optimizeDeps: {
    // include: ['@dcloudio/uni-ui']
  },
  build: {
    // 开启 sourcemap 映射源码
    sourcemap: true
  },
  plugins: [
    uni({
      vueOptions: {
        // 开启响应性语法糖
        reactivityTransform: true
      }
    }),
    eslint()
    // AutoImport({
    //   resolvers: [ElementPlusResolver()],
    //   imports: ['vue', 'vue-router', 'pinia'],
    //   eslintrc: {
    //     enabled: false,
    //     filepath: './.eslintrc-auto-import.json',
    //     globalsPropValue: true
    //   }
    // })
  ],
  server: {
    // port: 8080,
    host: '0.0.0.0',
    // proxy: {
    //   '/api/': {
    //     target:
    //       'https://service-rbji0bev-1256505457.cd.apigw.tencentcs.com/release',
    //     changeOrigin: true,
    //     rewrite: (p) => p.replace(/^\/api/, '')
    //   },
    //   '/api-prod/': {
    //     target: 'http://localhost:3001',
    //     changeOrigin: true,
    //     rewrite: (p) => p.replace(/^\/api-prod/, '')
    //   }
    // }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '@components': path.resolve(__dirname, './src/components')
    }
  },
  css: {
    // 配置`scss`和`less`全局变量
    preprocessorOptions: {
      scss: {
        additionalData: '@import "@/styles/vars/_base.scss";'
      },
      less: {
        additionalData: '@import "@/styles/vars/_base.less";'
      }
    }
  },
  define: {
    'process.env.config': 'ENV_CONFIG'
  }
})
